<template>
  <div class="title">ref的另一种用法</div>
  <input ref="inp" type="text" placeholder="请输入">
</template>

<script lang="ts">
import {defineComponent, ref, onMounted} from 'vue';

export default defineComponent({
  name: 'App',
  components: {},
  setup() {
    const inp = ref<HTMLElement | null>(null)

    onMounted(() => {
      inp.value && inp.value.focus()
    })

    return {
      inp
    }
  },

});
</script>

<style>
.title {
  margin-bottom: 20px;
}
</style>
